﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Admin/Views/Shared/Site.Master"
    Inherits="System.Web.Mvc.ViewPage<IEnumerable<Model.Category>>" %>
<%@ Import Namespace="UI.Helper" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Danh mục bất động sản
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <!--  start page-heading -->
	<div id="page-heading">
		<h1>Quản Lý Danh Mục Bất Động Sản</h1>
	</div>
	<!-- end page-heading -->

    <table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
        <tr>
		    <th rowspan="3" class="sized"><img src="<%= Utils.ResolveUrl(this.Html, "~/") %>images/admin/shared/side_shadowleft.jpg" width="20" height="300" alt="" /></th>
		    <th class="topleft"></th>
		    <td id="tbl-border-top">&nbsp;</td>
		    <th class="topright"></th>
		    <th rowspan="3" class="sized"><img src="<%= Utils.ResolveUrl(this.Html, "~/") %>images/admin/shared/side_shadowright.jpg" width="20" height="300" alt="" /></th>
	    </tr>

        <tr>
            <td id="tbl-border-left"></td>
		    <td>
		    <!--  start content-table-inner ...................................................................... START -->
            <div id="content-table-inner">

                <!--  start table-content  -->
                <div id="table-content">
                    <!--  start message-red -->
                    <%
                        var displayError = "none";

                        if (TempData[Constants.MESSAGE] != null)
                            displayError = "block";
                    %>
                    <div id="message-red" style="display:<%: displayError %>">
				    <table border="0" width="100%" cellpadding="0" cellspacing="0">
				        <tr>
					        <td class="red-left"><%: TempData[Constants.MESSAGE]%></td>
                            <td class="red-right"><a class="close-red"><img alt="" src="<%: Url.Content("~/Images/admin/table/icon_close_red.gif")%>"></a></td>
				        </tr>
				    </table>
				    </div>
				    <!--  end message-red -->
                    <!--  start table ..................................................................................... -->
				    <form id="mainform" action="">
                    <table border="0" width="100%" cellpadding="0" cellspacing="0" id="product-table">
                        <tr>
                            <th class="table-header-check"><a id="toggle-all" ></a></th>
					        <th class="table-header-repeat line-left minwidth-1"><label>Tên</label></th>
                            <th class="table-header-repeat line-left minwidth-1"><label>Hình</label></th>
                            <th class="table-header-options line-left"><label>Tùy chọn</label></th>
				        </tr>
                        <% foreach (var tmp in Model)
                        { %>

                        <tr>
					        <td><input value="<%: tmp.Id %>" type="checkbox"/></td>
					        <td><%: tmp.Name %></td>
                            <td><img alt="" width="100" height="100" src="<%: tmp.ImageUrl %>"/></td>
					        <td class="options-width">
                                <%: Html.ActionLink(" ", "Edit", new { area = "Admin", controller = "Category", id = tmp.Id }, new { @class = "icon-1 info-tooltip" })%>
                                <%: Html.ActionLink(" ", "Delete", new { area = "Admin", controller = "Category", id = tmp.Id }, new { @class = "icon-2 info-tooltip", onclick = "return ConfirmDelete();" })%>
					            <%--<a href="" title="Edit" class="icon-1 info-tooltip"></a>
					            <a href="" title="Delete" class="icon-2 info-tooltip"></a>
					            <a href="" title="Edit" class="icon-3 info-tooltip"></a>
					            <a href="" title="Edit" class="icon-4 info-tooltip"></a>
					            <a href="" title="Edit" class="icon-5 info-tooltip"></a>--%>
					        </td>
				        </tr>

                        <% } %>
                    </table>
                </form>
                </div>
                <!--  end content-table  -->

                <!--  start actions-box ............................................... -->
			    <div id="actions-box">
                    <%--<h3><a href="<%= Utils.ResolveUrl(this.Html, "~/Admin/Category/Add") %>"><img width="21" height="21" alt="" src="<%= Utils.ResolveUrl(this.Html, "~/") %>images/admin/forms/icon_plus.gif"> Thêm danh mục</a></h3>--%>
				    <a href="" class="action-slider"></a>
				    <div id="actions-box-slider">
                        <%: Html.ActionLink("Thêm", "Add", new { area = "Admin", controller = "Category" }, new { @class = "action-edit" })%>
                        <%: Html.ActionLink("Xóa", "DeleteAll", new { area = "Admin", controller = "Category" }, new { @class = "action-delete", onclick ="return SubmitDelete(this);" })%>
				    </div>
				    <div class="clear"></div>
			    </div>
			    <!-- end actions-box........... -->
			
			    <!--  start paging..................................................... -->
                <% if (Model.Count() > 0)
                   { %>
			    <table border="0" cellpadding="0" cellspacing="0" id="paging-table">
			    <tr>
			    <td>
                    <%: Html.ActionLink(" ", "PagingData", new { area = "Admin", controller = "Category", pageIndex = 1 }, new { @class = "page-far-left" })%>
                    <%: Html.ActionLink(" ", "PagingData", new { area = "Admin", controller = "Category", pageIndex = ((int)ViewData[Constants.PAGE_INDEX] - 1) < 1 ? 1 : ((int)ViewData[Constants.PAGE_INDEX] - 1) }, new { @class = "page-left" })%>
				    <div id="page-info">Trang <strong><%: ViewData[Constants.PAGE_INDEX]%></strong> / <%: ViewData[Constants.TOTAL_PAGE]%></div>
                    <%: Html.ActionLink(" ", "PagingData", new { area = "Admin", controller = "Category", pageIndex = ((int)ViewData[Constants.PAGE_INDEX] + 1) > (int)ViewData[Constants.TOTAL_PAGE] ? ViewData[Constants.TOTAL_PAGE] : ((int)ViewData[Constants.PAGE_INDEX] + 1) }, new { @class = "page-right" })%>
                    <%: Html.ActionLink(" ", "PagingData", new { area = "Admin", controller = "Category", pageIndex = ViewData[Constants.TOTAL_PAGE] }, new { @class = "page-far-right" })%>
			    </td>
			    </tr>
			    </table>
                <% } %>
			    <!--  end paging................ -->
			
			    <div class="clear"></div>
            </div>
            </td>
            <td id="tbl-border-right"></td>
        </tr>
        <tr>
		    <th class="sized bottomleft"></th>
		    <td id="tbl-border-bottom">&nbsp;</td>
		    <th class="sized bottomright"></th>
	    </tr>
    </table>

    <script type="text/javascript">
        function ConfirmDelete() {
            var res = confirm("Bạn muốn xóa dữ liệu này?");

            return res;
        }

        function SubmitDelete(obj) {
            var ids = "";
            $(".ui-helper-hidden-accessible").each(function () {
                if (ids == "")
                    ids += this.value;
                else
                    ids += "," + this.value;
            });

            if (ids == "") {
                alert("Vui lòng chọn dữ liệu cần xóa.");
            }
            else
                location.href = obj.href + "/" + ids;
            return false;
        }
    </script>
</asp:Content>
